package com.lcgroup.springdemo.demos.handler;

import com.lcgroup.springdemo.demos.bean.ResultResponse;
import com.lcgroup.springdemo.demos.bean.ZSException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestControllerAdvice
@Slf4j
public class GlobeExceptionHandler {


    @ExceptionHandler(ZSException.class)
    public ResultResponse<String> handleException(Exception e){
        ResultResponse<String> fail = new ResultResponse<>("fail", e.getMessage(), "");
        log.info(fail.toString());
        return fail;
    }
}
